<?php
namespace app\admin\controller;

use controller\BasicAdmin;
use service\DataService;
use think\Db;

/**
 * 集团公司管理控制器
 * Class Groupcompany
 * @package app\admin\controller
 * @author ma <80234043@qq.com>
 * @date 2022/02/12 18:12
 */
class Groupcompany extends BasicAdmin
{
    /**
     * 指定当前数据表
     * @var string
     */
    public $table = 'SystemGroupCompany';

    //列表
    public function index(){
        $this->title = '集团公司管理';
        $get = $this->request->get();
        $db = Db::name($this->table)->where(['is_deleted' => '0']);
        foreach (['name', 'country'] as $key) {
            (isset($get[$key]) && $get[$key] !== '') && $db->whereLike($key, "%{$get[$key]}%");
        }
        return parent::_list($db);

    }

    //添加
    public function add(){
        return $this->_form($this->table, 'form',$pkField = '', $where = [], $extendData = ['create_at'=>time(),'create_by'=>session("user.id")]);
    }

    //修改
    public function edit(){
        return $this->_form($this->table, 'form',$pkField = '', $where = [], $extendData = ['create_at'=>time(),'create_by'=>session("user.id")]);
    }

    //删除
    public function del(){
        if (DataService::update($this->table)) {
            $this->success("删除成功!", '');
        }
        $this->error("删除失败, 请稍候再试!");
    }
}